/*******************************************************************************
 * Copyright (c) 2010, 2030 www.mahao.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/** 
 * ClassName: Main <br/> 
 * Function: TODO 功能描述 <br/> 
 * date: 2017年6月6日 上午11:01:46 <br/> 
 * 
 * @author Mmmmm 
 * @version  
 * @since JDK 1.8 
 */
public class Main {

	/** 
	 * main:(这里用一句话描述这个方法的作用). <br/>
	 * 
	 * @author Mmmmm 
	 * @param args 
	 * @since JDK 1.8 
	 */
	public static void main(String[] args) {
		UserDao userDaoTarget = new UserDaoImpl();
		UserDao userDao = (UserDao) Proxy.newProxyInstance(UserDao.class.getClassLoader()
				, UserDaoImpl.class.getInterfaces()
				, new InvocationHandler() {
					@Override
					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
						System.out.println("[日志]--Start");
						Object result = method.invoke(userDaoTarget, args);
						System.out.println("[日志]--End"+result);
						return result;
					}
				});
		userDao.save("张三");
	}

}
